﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows;
using System.Windows.Media.Media3D;
using System.Windows.Media;

namespace GeoPlugin
{
    public class MapHandlers
    {
        public static void AddClickHandlerForMap(Image image, String mapName)
        {
            switch (mapName)
            {
                case "Europe":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(EuropeMap_MouseRightButtonUp);
                    image.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(EuropeMap_MouseLeftButtonUp);
                    break;
                case "Africa":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(AfricaMap_MouseRightButtonUp);
                    break;
                case "North America":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(NorthAmericaMap_MouseRightButtonUp);
                    break;
                case "Australia":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(AustraliaMap_MouseRightButtonUp);
                    break;
                case "Asia":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(AsiaMap_MouseRightButtonUp);
                    break;
                case "South America":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(SouthAmericaMap_MouseRightButtonUp);
                    break;
                case "Antartica":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(AntarticaMap_MouseRightButtonUp);                    
                    break;
                case "Romania":
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(RomaniaMap_MouseRightButtonUp);
                    break;
                default:
                    image.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(EuropeMap_MouseRightButtonUp);
                    break;
            }
        }

        static void SetVisibleElement(MapControl mapControl, Image currentMap)
        {
            ((MapControl)((Grid)(currentMap.Parent)).Parent).Opacity = 0;
            ((Grid)((MapControl)((Grid)(currentMap.Parent)).Parent).Parent).Children.Add(mapControl);
            
        }

        static void EuropeMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point p = e.GetPosition((IInputElement)sender);
            //Here we have to check for the position of each country and add the specific map
            //Also we have to display the information on mouse over. For now on leftmouseclick
            if (true)
            {
             //   MapControl mapControl = new MapControl(new Image(), "Romania");
             //   GeoPlugin.IncreaseBackButtonLevel();
             //   SetVisibleElement(mapControl, (Image)sender);
            }
        }

        static void EuropeMap_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point mouseposition = e.GetPosition((IInputElement)sender);
            if (true)
            {
                Console.WriteLine("Romania");
            }
        }

        static void RomaniaMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point p = e.GetPosition((IInputElement)sender);
            if (true)
            {
             //   MapControl mapControl = new MapControl(new Image(), "Romania");
             //   SetVisibleElement(mapControl, (Image)sender);
            }
        }

        static void AfricaMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void AustraliaMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void NorthAmericaMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void SouthAmericaMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void AntarticaMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void AsiaMap_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            throw new NotImplementedException();
        }
    }
}
